var a = getApp();

Page({
    data: {
        bank_name: "",
        bank_id: "",
        bank_user: "",
        bank_province: "",
        bank_city: "",
        bank_branch: "",
        status: !1,
        result: "1"
    },
    onLoad: function(a) {
        this._getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    banknameinp: function(a) {
        var t = a.detail.replace(/[0-9]+/g, "");
        this.setData({
            bank_name: t.trim()
        });
    },
    onChangRadio: function(a) {
        this.setData({
            result: a.detail
        });
    },
    bankprovinceinp: function(a) {
        var t = a.detail.value;
        this.setData({
            bank_province: t.trim()
        });
    },
    bankcityinp: function(a) {
        var t = a.detail.value;
        this.setData({
            bank_city: t.trim()
        });
    },
    bankbranchinp: function(a) {
        var t = a.detail.value;
        this.setData({
            bank_branch: t.trim()
        });
    },
    bankidinp: function(a) {
        var t = a.detail.value;
        this.setData({
            bank_id: t.trim()
        });
    },
    bankuserinp: function(a) {
        var t = a.detail.value;
        this.setData({
            bank_user: t.trim()
        });
    },
    _getData: function() {
        var t = this, n = a.getNetAddresss("member.bank-card.show");
        a._postNetWork({
            url: n,
            showToastIn: !1,
            data: this.data.form,
            success: function(a) {
                var n = a.data;
                1 == n.result ? t.setData({
                    bank_name: n.data.bank_name,
                    bank_id: n.data.bank_card,
                    bank_user: n.data.member_name,
                    bank_province: n.data.bank_province,
                    bank_city: n.data.bank_city,
                    bank_branch: n.data.bank_branch
                }) : wx.showToast({
                    icon: "none",
                    title: n.msg,
                    duration: 1500
                });
            },
            fail: function(a) {
                console.log(a.msg);
            }
        });
    },
    change: function() {
        this.setData({
            status: !0,
            bank_id: ""
        });
    },
    bind: function() {
        if (a._isTextEmpty(this.data.bank_name)) wx.showToast({
            icon: "none",
            title: "请输入开户行",
            duration: 1500
        }); else if (a._isTextEmpty(this.data.bank_province)) wx.showToast({
            icon: "none",
            title: "请输入开户行省份",
            duration: 1500
        }); else if (a._isTextEmpty(this.data.bank_city)) wx.showToast({
            icon: "none",
            title: "请输入开户行城市",
            duration: 1500
        }); else if (a._isTextEmpty(this.data.bank_branch)) wx.showToast({
            icon: "none",
            title: "请输入开户行支行",
            duration: 1500
        }); else if (a._isTextEmpty(this.data.bank_id)) wx.showToast({
            icon: "none",
            title: "请输入账号",
            duration: 1500
        }); else if (a._isTextEmpty(this.data.bank_user)) wx.showToast({
            icon: "none",
            title: "请输入姓名",
            duration: 1500
        }); else {
            var t = {
                bank_card: this.data.bank_id,
                member_name: this.data.bank_user,
                bank_name: this.data.bank_name,
                bank_province: this.data.bank_province,
                bank_city: this.data.bank_city,
                bank_branch: this.data.bank_branch,
                bank_type: this.data.result
            }, n = a.getNetAddresss("member.bank-card.edit");
            a._postNetWork({
                url: n,
                showToastIn: !1,
                data: t,
                success: function(a) {
                    var t = a.data;
                    1 == t.result ? wx.showToast({
                        title: t.msg,
                        icon: "none",
                        duration: 1500,
                        success: function() {
                            setTimeout(function() {
                                wx.navigateBack({
                                    delta: 1
                                });
                            }, 1500);
                        }
                    }) : wx.showToast({
                        icon: "none",
                        title: t.msg,
                        duration: 1500
                    });
                },
                fail: function(a) {
                    console.log(a.msg);
                }
            });
        }
    }
});